Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lower _d_arraycast to object.__ArrayCast #8531

Closed
wants to merge 1 commit into from
Closed

Lower _d_arraycast to object.__ArrayCast #8531

wants to merge 1 commit into from

Conversation

JinShil
Copy link
Contributor

@JinShil JinShil commented Aug 2, 2018

Requires dlang/druntime#2264 to be merged first

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @JinShil!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#8531"


// lower to `object.__ArrayCast!(TFrom, TTo)(from)`

auto id = Identifier.idPool("__ArrayCast");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I fully qualify this to object.__ArrayCast?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at how the comparison lowering is done to __cmp.

dmd/src/dmd/expressionsem.d

Lines 9794 to 9798 in 03e7693

// Lower to object.__cmp(e1, e2)
Expression al = new IdentifierExp(exp.loc, Id.empty);
al = new DotIdExp(exp.loc, al, Id.object);
al = new DotIdExp(exp.loc, al, Id.__cmp);
al = al.expressionSemantic(sc);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I need an Identifer, not an Expression, for the TemplateInstance, later. How do I create a fully-qualified Identifier?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I create a fully-qualified Identifier?

I don't think that is possible. To get the fully qualified name inside the compiler one needs to walk up the parent chain and build up the name that way. In your case, I think you need to use the overload of the TemplateInstance constructor that takes a TemplateDeclaration. Perhaps you can store the TemplateDeclaration when it's analyzed in the same way as the Object class declaration (and others) is stored:

dmd/src/dmd/dclass.d

Lines 367 to 372 in 03e7693

if (id == Id.Object)
{
if (!inObject)
error("%s", msg);
object = this;
}


// size mismatch, should result in an assertion failure
l = cast(long[])b;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants